<template>
	<view class="login">
		<image src="../../static/logo.png" mode=""></image>
		<button @click="login">微信授权登录</button>
	</view>
</template>

<script setup>
	function login() {
		uni.login({
			success(res) {
				console.log(res)
				uni.showLoading({
					title: '登陆中...'
				})
				let code = res.code
				uni.request({
					url: `https://api.weixin.qq.com/sns/jscode2session?appid=wx2371d78cdba99edf&secret=98b4e42df06ace352a68c8943edc596d&js_code=${code}&grant_type=authorization_code`,
					success(res) {
						console.log(res)
						res.data.phone = 13582208538
						uni.setStorageSync('userInfo', res.data)
						uni.navigateBack()
					}
				})
			}
		})
	}
</script>

<style lang="scss">
	page,
	.login {
		width: 100%;
		height: 100%;
	}
</style>